
# student_1 = {
#     "学号" : "111",
#     "姓名" : "张三",
#     "性别" : "男",
#     "年龄" : "19"
# }
#
# student_2 = {
#     "学号" : "222",
#     "姓名" : "李四",
#     "性别" : "男",
#     "年龄" : "18"
# }

#......

# class Student:
#     name = None
#     age = None
#
#     def __init__(self,name,age):
#         self.name = name
#         self.age = age
#
#     def say_hello(self):
#         print(f"您好，我叫{self.name} ")
#
#
# student = Student("小明",18);
# student.say_hello()
#
# class Student:
#     _name = None
#     _age = None
#
#     def __init__(self,name , age):
#         self._name = name
#         self._age = int(age)
#
#     def __str__(self):
#         return f"姓名是：{self._name}, 年龄是：{self._age}"
#
#     def __lt__(self,s):
#         return self._age < s._age
#
#     def __le__(self,s):
#         return self._age < s._age
#
#     def __eq__(self,s):
#         return self._age == s._age
#
# if __name__ =='__main__':
#      s1 = Student("小明",18)
#      print(s1)
#      s2 = Student("李华", 19)
#      print(s2)
#
#      print(s1>s2)
#      print(s2>s1)
#
#      print(s1 == s2)
#
# class Student:
#
#     # 构造方法
#     def __init__(self,id , name, sex, age):
#         self.id = id  #成员变量 年龄
#         self.name = name  #成员变量 姓名
#         self.sex = sex   #成员变量 性别
#         self.age = age   #成员变量 年龄
#
#    # 返回f"学号{self.id}, 姓名{self.name}, 性别{self.sex}, 年龄{self.age}字符串
#     def __str__(self):
#         return f"学号{self.id}, 姓名{self.name}, 性别{self.sex}, 年龄{self.age}"
#
#    # 年龄大于、小于比较
#     def __lt__(self,other):
#         return self.age < other.age
#
#    # 年龄大于等于、小于等于比较
#     def __le__(self,other):
#         return self.age <= other.age
#
#    # 年龄等于比较
#     def __eq__(self,other):
#         return self.age == other.age


# #创建对象，同时赋值
# student_1 = Student("111", "张三", "男", 19)
#
# student_2 = Student("222", "李四", "男", 18)
#
# # 自动调用__str__(self)
# print(student_1)
# print(student_2)
#
# # 自动调用__lt__(self,other)
# print(student_1 < student_2)
#
# # 自动调用__le__(self,other)
# print(student_1 >= student_2)
#
# # 自动调用__eq__(self,other)
# print(student_1 == student_2)

    # #成员方法
    # def Print(self):
    #     print(f"学号{self.id}, 姓名{self.name}, 性别{self.sex}, 年龄{self.age}")


# #创建对象，同时赋值
#
# student_1 = Student("111", "张三", "男", 19)
#
# student_2 = Student("222", "李四", "男", 18)
#
# print(student_1 < student_2)

# #创建一个对象
# student_1 = Student()
#
# # 对student_1 赋值
# student_1.id = "111"
# student_1.name = "张三"
# student_1.sex = "男"
# student_1.age = 19
#
# student_1.Print()

#
# # 对student_2 赋值
# student_2.id = "222"
# student_2.name = "李四"
# student_2.sex = "男"
# student_2.age = 18



# #使用上述创建的类来创建对象
#
# student_1 = Student("111", "张三", "男", 19)
#
# student_2 = Student("222", "李四", "男", 18)

# def Fun(self, 形参1， ....，形参N):
#     #方法体

# class Student:
#      #私有成员变量
#     __id = None
#     __name = None
#     __sex = None
#     __age = None
#
#    #这样的构造方法是错误的
#    # 私有变量无法赋值，也无法获取值，会报错
#    def __init__(self, id, name, sex, age):
#        self.id = id  # 成员变量 年龄
#        self.name = name  # 成员变量 姓名
#        self.sex = sex  # 成员变量 性别
#        self.age = age  # 成员变量 年龄
#
#   # 私有成员方法
#    def __Print(self):
#         print(f"学号{self.id}, 姓名{self.name}, 性别{self.sex}, 年龄{self.age}")
#
# #创建对象，同时赋值
# #私有变量无法赋值，也无法获取值，会报错
# student= Student("111", "张三", "男", 19)
#
# #私有方法无法直接被类对象使用
# student.Print()

class Test:
    n =None
    __m = None

    def __init__(self,n):
        self.n = n

    def __Print(self):
        print("私有成员")

    def Fun(self):
        # 在成员方法内可以调用私有成员变量
        self.n = 0

        # 在成员方法内可以调用私有成员方法
        print(self.n)
        self.__Print()


test = Test(9)
test.Fun()